package com.cos.emp.controller;

import com.cos.emp.common.entity.Emp;
import com.cos.emp.feign.EmpCustomerFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: COS
 * @time: 2022/4/28 14:30
 * @description:
 */
@RestController
@RequestMapping
public class EmpCustomerController {

    @Autowired
    private EmpCustomerFeignClient empClient;

    @GetMapping("/getEmpByEno/{eno}")
    public Emp getEmpByEno(@PathVariable Integer eno) {
        return empClient.getEmpByEno(eno);
    }


    @GetMapping(value = "/getEmpList")
    public List<Emp> getEmpList() {
        return empClient.getEmpList();
    }

    @GetMapping(value = "/updateEmp")
    public String updateEmp(Emp emp) {
        if (empClient.updateEmp(emp)) {
            return "你醒了你现在是个女孩子了";
        }
        return "恭喜,你生了孩子";
    }

    @GetMapping(value = "/addEmp")
    public String addEmp(Emp emp) {
        if (empClient.addEmp(emp)) {
            return "成功";
        }
        return "失败";
    }

    @GetMapping(value = "/delEmp/{eno}")
    public String delEmp(@PathVariable Integer eno) {
        if (empClient.delEmp(eno)) {
            return "删除成功";
        }
        return "删除失败";

    }
}
